const { readFileSync, writeFileSync } = require('fs')

; ((async () => {
    const rawData = readFileSync('./bankData').toString()
    const banks = rawData.split('\n').map(line => {
      const [code, abbreviation, name] = line.split(',')
      return {
        code, abbreviation, name
      }
    })
    const putBankCodes = banks.map(bank =>
      `put("${bank.name}", new BJCJBank("${bank.code}", "${bank.abbreviation}", "${bank.name}"));`
    ).join('\n        ')

    const code = `
      static final HashMap bankMap = new HashMap<String, BJCJBank>() {{
        ${putBankCodes}
      }};
    `
    console.log(putBankCodes)
    writeFileSync('./bankRes', code)
})())